package com.imagination.applet.domain.product.model;

import com.imagination.applet.domain.adapter.OSSConfiguration;
import com.imagination.applet.domain.common.entity.AbstractEntity;
import com.imagination.applet.domain.utils.OssUtil;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.springframework.util.StringUtils;

@SuperBuilder
@Entity
@Table(name = "t_product_images")
@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class ProductImage extends AbstractEntity {

    @Column(name = "user_id")
    private Long userId;

    @Column(name = "virtual_identity_id")
    private Long virtualIdentityId;

    @Column(name = "ai_image_id")
    private Long aiImageId;
    @Column(name = "original_photo")
    private Long originalPhoto;

    @Column(name = "channel_type")
    private String channelType;

    @Column(name = "task_id")
    private String taskId;

    @Column(name = "training_status")
    private Integer trainingStatus;

    @Column(name = "image_path")
    private String imagePath;

    @Column(name = "deleted", insertable = false)
    private Integer deleted;

    @Column(name = "is_hd")
    private Integer isHd;

    public String getLink() {
        return StringUtils.hasText(imagePath) ? OssUtil.getTempUrl(imagePath) : null;
    }
}
